package com.vhall.component.controller.preparation;

import com.vhall.component.controller.preparation.facade.InviteConsoleFacade;
import com.vhall.component.entity.preparation.InviteCardsEntity;
import com.vhall.component.entity.preparation.vo.*;
import com.vhall.component.framework.common.annotation.VhallComponent;
import com.vhall.component.framework.common.exception.BusinessException;
import com.vhall.component.plugin.common.annotation.TokenAuth;
import com.vhall.component.plugin.common.exception.BizErrorCode;
import com.vhall.component.service.preparation.InviteCardService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author guoxin.wang
 * @date 2021/7/8 15:30
 */
@VhallComponent
public class InviteConsoleController implements InviteConsoleFacade {

    @Autowired
    private InviteCardService inviteCardService;

    @TokenAuth
    @Override
    public SetInviteCardRespVO<InviteCardsEntity> setInviteCard(SetInviteCardReqVO reqVO) {
        return inviteCardService.setInviteCard(reqVO);
    }

    @TokenAuth
    @Override
    public Boolean updateInviteCard(UpdateInviteCardReqVO reqVO) {
        return inviteCardService.updateInviteCard(reqVO);
    }

    @TokenAuth
    @Override
    public String switchInviteCard(SwitchInviteCardReqVO reqVO) {
        return inviteCardService.switchInviteCard(reqVO);
    }

    @TokenAuth
    @Override
    public UploadInviteCardRespVO upload(UploadInviteCardReqVO reqVO) {
        String roomId = reqVO.getRoomId();
        String accountId = reqVO.getAccountId();
        if (StringUtils.isEmpty(roomId) && StringUtils.isEmpty(accountId)) {
            throw new BusinessException(BizErrorCode.BIZ_INVALID_PARAM);
        }
        if (StringUtils.isNotEmpty(roomId) && StringUtils.isNotEmpty(accountId)) {
            throw new BusinessException(BizErrorCode.BIZ_INVALID_PARAM);
        }
        return inviteCardService.upload(reqVO);
    }

}
